package com.example.dell.utils;

import android.media.AudioManager;
import android.media.SoundPool;

import com.example.dell.basic.AppComplication;
import com.example.dell.basicapplication.R;

public class UmsicUtils {
    private static final UmsicUtils instance = new UmsicUtils();
    private              SoundPool  mSoundPool;
    private              int        mDuanSound;
    private              int        mYuluSound;

    //这里提供了一个供外部访问本class的静态方法，可以直接访问
    public static UmsicUtils getInstance(){
        return instance;
    }

    public void musicPlay(boolean isPaly){
        if (mSoundPool==null) {
            mSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
            //预加载音乐
            mDuanSound = mSoundPool.load(AppComplication.mContext, R.raw.duan, 1);
        }
        if (isPaly){
            mSoundPool.play(mDuanSound, 1, 1, 0, 0, 1);
        }

        //        mYuluSound = mSoundPool.load(CompontApplayCation.context, R.raw.yulu, 1);
    }
}
